package com.processor;

import com.entity.Student;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class CustomBeanPostProcessor implements BeanPostProcessor {

    Logger logger = LoggerFactory.getLogger(getClass());


    public CustomBeanPostProcessor() {
        logger.info("===============BeanPostProcessor构造器===============");
    }


    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof Student) {
            logger.info("===============BeanPostProcessor.postProcessBeforeInitialization==============={}",bean.toString());
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {

        if (bean instanceof Student) {
            logger.info("===============BeanPostProcessor.postProcessAfterInitialization==============={}",bean.toString());
        }
        return bean;
    }
}
